{% extends "base.html" %}
<script type="text/javascript" src="/static/js/jquery.treeview.js"></script>
<script type="text/javascript" src="/static/js/jquery.cookie.js"></script>
{% block header %}
<link rel="stylesheet" type="text/css" href="/media/css/forms.css">
<script type="text/javascript" src="/static/js/jquery.treeview.js"></script>
<script type="text/javascript" src="/static/js/jquery.cookie.js"></script>
<script type="text/javascript" src="/static/js/date/WdatePicker.js"></script>
<script type="text/javascript">

function del(id){
    $.getJSON("/alert/delete?id="+ id, function(data, id){
        if(data['flag'] == 'true'){
            $('#ajaxStatus').html('1');
        }else{
            $('#ajaxStatus').html('0');
            alert('删除失败');
        }
    });
     ret = $('#ajaxStatus').html();
    if(ret == '1'){
        $('#' + id).remove();
    }
    
}

function add(mid,uid){
    $.getJSON("/alert/ajaxadd", {"mid": mid, "uid":uid}, function(data, id){
        if(data['flag'] == 'true'){
            $('#ajaxStatus').html('1');
        }else{
            $('#ajaxStatus').html('0');
            alert('添加失败');
        }
    });
     ret = $('#ajaxStatus').html();
    if(ret == '1'){
        $('#' + mid).html("添加成功");
    }
    
}

$(document).ready(function(){
	$("#f").hide();
	$("#search").click(function(){
		$("#f").show();
	});
	$("#shouqi").click(function(){
		$("#f").hide();
	});

});
</script>
{% endblock %}

{% block menu %}
    {% include "alert-menu.html" %}
{% endblock %}

{% block content %}
    <div id="ajaxStatus" style="display:None">0</div>
	<div id="mon-tit">
	    <div class="left">报警管理 >> 报警接受列表</div>
	</div>
	<div class="clr"></div>
	<hr />
	<h3 class="tit">报警接受列表</h3>
	<div  class="flow-dis">
	    <div class="title">
	        <span style="width:20%">编号</span>
	        <span style="width:30%">监控名称</span>
	        <span style="width:25%">接受人</span>
	        <span style="width:25%">操作</span>
	    </div>
	  {% for a in  alert %}
	    <div class="{% cycle 'ji' 'ou' %}" id='{{a.id}}'>
	        <span style="width:20%">{{ a.id }}</span>
	        <span style="width:30%">{{ a.mid }}</span>
	        <span style="width:25%">{{ a.uid }}</span>
	        <span style="width:25%"><a href='javascript:del({{a.id}});'>删除</a></span>
	    </div>
	{% endfor %}
	</div>

    <h3 class="tit">报警添加列表</h3>
	<div  class="flow-dis">
	    <div class="title">
	        <span style="width:20%">编号</span>
	        <span style="width:30%">监控名称</span>
	        <span style="width:25%">URL</span>
	        <span style="width:25%">操作</span>
	    </div>
	  {% for m in  monitor %}
	    <div class="{% cycle 'ji' 'ou' %}">
	        <span style="width:20%">{{ m.id }}</span>
	        <span style="width:30%">{{ m }}</span>
	        <span style="width:25%">{{ m.url }}</span>
	        <span style="width:25%" id='{{m.id}}'><a href='javascript:add({{m.id}}, {{uid}});'>添加</a></span>
	    </div>
	{% endfor %}
        <div>注意：批量添加和删除报警人以后，请重启监控服务端，否则不生效</div>

{% endblock %}
